/* Copyright (c) 2010, David Kreuter. See LICENSE for more information */

extern "C"{
#include "headers.h"
}

int main(int argc, char **argv){
	uint8 *buf; uint32 len; narc *n;
	if(argc!=4)return 1;

	if(!read_file(argv[1],&buf,&len))return 2;
	if(!(n=read_narc(buf,len))) return 3;
	free(buf); len=0;

	int index=atoi(argv[2]);

	if(!write_file(argv[3],&n->file[index],&n->size[index]))return 4;
	free_narc(n);

	return 0;
}
